package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.XSlf4j;
import org.example.entity.Goods;
import org.example.mapper.GoodsMapper;
import org.example.service.GoodsService;
import org.springframework.stereotype.Service;

import java.util.List;

@AllArgsConstructor
@Service
@Slf4j
public class GoodsServiceImpl implements GoodsService {
    private final GoodsMapper goodsMapper;

    public List<Goods> findAll() {
        QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
        queryWrapper.gt("g_id", 2);
        List<Goods> goods = goodsMapper.selectList(queryWrapper);
//        goods.toString();
        log.info("Fetched goods: " + goods);
        if (goods == null || goods.contains(null)) {
            throw new RuntimeException("Fetched goods list contains null values");
        }
        return goods;
    }

    public List<Goods> getAllGoods() {
        return goodsMapper.selectList(null);
    }


}
